import java.util.Scanner;

class Ticket {
    public static int num = 30;// 电影院票数量

    public static int Addnum(int m) {
        num = num + m;// 增
        return (num);
    }
    public static int Cutnum(int m) {
        num = num - m;
        return (num);// 删
    }
    public static int Getnum() {
        return num;
    }

    public static void Setnum(int num) {
        Ticket.num = num;
    }
}

class Operation {
    public static void BuyTicket(int m) {// 买票
        if (m == 0) {
            System.out.println("错误");
        } else {
            System.out.println("购票成功");
            Ticket.Cutnum(m);
            System.out.println("本影院现存票数为" + Ticket.Getnum());
        }
    }

    public static void RefundTicket(int m1) {// 退票
        System.out.println("退票成功");
        Ticket.Addnum(m1);
        System.out.println("本影院现存票数为" + Ticket.Getnum());
    }

}

public class piao {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        while (true) {

            System.out.println("输入1（进行买票），输入2（进行退票），输入0（退出）");
            Scanner reader = new Scanner(System.in);
            int n = reader.nextInt();
            switch (n) {
                case 1:
                    System.out.println("您需要订购几张票：");
                    Scanner b = new Scanner(System.in);
                    int m = b.nextInt();
                    if (Ticket.num == 0 || Ticket.num < m) {
                        System.out.println("暂无票^-^");
                    } else
                        Operation.BuyTicket(m);
                    break;
                case 2:
                    System.out.println("您需要退几张票：");
                    Scanner b1 = new Scanner(System.in);
                    int m1 = b1.nextInt();
                    if (m1 == 0) {
                        System.out.println("请输入你想退的票数");
                        break;
                    } else
                        Operation.RefundTicket(m1);
                    break;
                case 0:
                    System.exit(-1);
                    break;
                default:
                    System.out.println("输入错误，请重新输入");
                    break;
            }
        }
    }
}